<template>
    <div class="layout-padding-auto layout-padding-view">
        <el-table :data="state.dataList" highlight-current-row v-loading="state.loading" border
            style="width: 100%; height: 100%"  stripe
            :header-cell-style="tableStyle.headerCellStyle" ref="tableRef" row-key="id">
            
            <el-table-column prop="materialCode" :label="$t('bom.materialCode')" show-overflow-tooltip />
            <el-table-column prop="materialName" :label="$t('bom.materialName')" show-overflow-tooltip align="center"/>
            <el-table-column prop="unit" :label="$t('bom.unit')" show-overflow-tooltip align="center"/>
            <el-table-column prop="standardQty" :label="$t('bom.standardQty')" show-overflow-tooltip align="center"/>
            <el-table-column prop="actualQty" :label="$t('bom.actualQty')" show-overflow-tooltip align="center"/>
            <el-table-column prop="numerator" :label="$t('bom.numerator')" show-overflow-tooltip align="center"/>
            <el-table-column prop="denominator" :label="$t('bom.denominator')" show-overflow-tooltip align="center"/>
            <el-table-column prop="fixscrapQty" :label="$t('bom.fixscrapQty')" show-overflow-tooltip align="center"/>
            <el-table-column prop="scraprate" :label="$t('bom.scraprate')" show-overflow-tooltip align="center"/>
        </el-table>
    </div>
</template>
<script setup lang="ts">
import { BasicTableProps, useTable } from "/@/hooks/table";
import { ref, reactive } from 'vue';
import { queryBomDetails } from '/@/api/platform/digital/basBom';
import { TabsPaneContext, ElMessage } from 'element-plus';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();

const state: BasicTableProps = reactive<BasicTableProps>({
    queryForm: {
        SourceCode: ''
    },
    pageList: queryBomDetails
})

const {
    getDataList,
    currentChangeHandle,
    sizeChangeHandle,
    tableStyle
} = useTable(state)
const tableRef = ref();
// 搜索变量
const queryRef = ref();

// 清空搜索条件
const resetQuery = () => {
    // 清空搜索条件
    queryRef.value?.resetFields()
    getDataList()
}
// 通过id进行子表的查询
const query = (row: Object) => {
    // 赋值查询参数
    console.info(row)
    state.queryForm.BomHId=row.id;
    // 刷新子表数据
    getDataList()
}
// 暴露变量
defineExpose({
    resetQuery,
    query
});

</script>